<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap.css"/>
<link rel="stylesheet" href="<%=basePath %>css/buttons.css" />
<script type="text/javascript" src="<%=basePath %>js/WdatePicker.js" ></script>
<!-- 城市选择js -->
<script type="text/javascript" src="<%=basePath %>js/selCity/cityList.js" ></script>
<!-- 表单验证js -->
<script src="<%=basePath %>js/Form validation/jquery-1.4.4.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="<%=basePath %>css/Form validation/validator.css"></link>
<script src="<%=basePath %>js/Form validation/formValidator-4.0.1.js" type="text/javascript" charset="UTF-8"></script>
<script src="<%=basePath %>js/Form validation/formValidatorRegex.js" type="text/javascript" charset="UTF-8"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<script type="text/javascript">
/* $(document).ready(function(){
	$.formValidator.initConfig({ formID: "form1", onError: function () { alert("校验没有通过，具体错误请看错误提示！") } });
	$("#trainnumber").formValidator({onShow:"请输入车次",onFocus:"长度6-20个字符!",onCorrect:"输入正确！"}).inputValidator({min:6,max:20,empty:{leftEmpty:false,rightEmpty:false,emptyError:"车次两边不能有空符号!"},onError:"车次不能为空或长度不符，请检查！"});
 	$("#startstation").formValidator({onShow:"请选择始发地",onFocus:"必须选择！",onCorrect:"选择正确！"}).inputValidator({min:1,empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#endstation").formValidator({onShow:"请选择终点站",onFocus:"必须选择！",onCorrect:"选择正确！"}).inputValidator({min:1,empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#starttime").formValidator({onShow:"请选择发车时间",onFocus:"必须选择！",onCorrect:"选择正确！"}).inputValidator({min:1,empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#endtime").formValidator({onShow:"请选择到达时间",onFocus:"必须选择！",onCorrect:"选择正确！"}).inputValidator({min:1,empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#viastaion1").formValidator({onShow:"请选择中途停靠站",onFocus:"中途停靠站可不选",onCorrect:"选择正确！"}).inputValidator({empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#viastaion2").formValidator({onShow:"请选择中途停靠站",onFocus:"中途停靠站可不选",onCorrect:"选择正确！"}).inputValidator({empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#viastaion3").formValidator({onShow:"请选择中途停靠站",onFocus:"中途停靠站可不选",onCorrect:"选择正确！"}).inputValidator({empty:{leftEmpty:false,rightEmpty:false,emptyError:""},onError:"忘记选择！"});
 	$("#total").formValidator({onShow:"请输入车票数",onCorrect:"输入正确！"}).regexValidator({regExp:"intege1",dataType:"enum",onError:"车票数格式不正确，请检查！"});
}); */
$(document).ready(function(){
	$("#btnUpdate").click(function() {
		var $form = $("form");
        $.ajax({
            cache: true,
            type: "POST",
            url: $form.attr("action"),	//提交的url
            data: $form.serialize(),
            async: false,
            success: function (data) {
            	alert("1！");
                location.reload();
            },
            error: function (request) {
                alert("2！");
                location.reload();
            }
        });
    });
	$("#exit").click(function(){
		location.href = "<%=basePath %>seltrain.jsp";
	});
});
</script>
<body onload="">
	<br />
	<center>
		<form action="<%=basePath %>trainInfo/update" method="post" role="form" id="form1">
			<table width="700" cellpadding="0" border=0" align="center">
				<c:forEach items="${trainList }" var="trainList">
					<tr>
						<td align="right" width="300">车次：</td>
						<td width="200"><input id="trainnumber" name="trainnumber" class="form-control" style="width:160px;height:25px;" value="${trainList.trainnumber }" readonly></td>
						<td ><div id="trainnumberTip" style="width:250px"></div></td>	
					</tr>	
					<tr>
						<td align="right">始发地：</td>
						<td><input id="startstation" name="startstation" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" value="${trainList.startstation }"></td>
						<td><div id="startstationTip" style="width:250px"></div></td>						
					</tr>
					<tr>
						<td align="right">终点站：</td>
						<td><input id="endstation" name="endstation" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)"  value="${trainList.endstation }"></td>
						<td><div id="endstationTip" style="width:250px"></div></td>				
					</tr>
					<%-- <tr>
						<td align="right">发车时间：</td>
						<td>
							<input id="starttime" name="starttime" type="text"
							value="${trainList.starttime }" class="form-control"
							style="width: 160px; height: 25px;"  
							onclick="WdatePicker( {el:this,dateFmt:'yyyy-MM-dd HH:mm:ss'} )" 
						    readonly>
						</td>
						<td><div id="starttimeTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td align="right">到达时间：</td>
						<td><input id="endtime" name="endtime" type="text" value="${trainList.endtime }" class="form-control" style="width:160px;height:25px;" onclick="WdatePicker( {el:this,dateFmt:'yyyy-MM-dd HH:mm:ss'} )" pattern="yyyy-MM-dd HH:mm:ss" readonly></td>
						<td><div id="endtimeTip" style="width:250px"></div></td>
					</tr> 
					<tr>
						<td align="right">放票时间：</td>
						<td><input id="puttickettime" name="puttickettime" type="text" value="${trainList.endtime }" class="form-control" style="width:160px;height:25px;" onclick="WdatePicker( {el:this,dateFmt:'yyyy-MM-dd HH:mm:ss'} )" pattern="yyyy-MM-dd HH:mm:ss" readonly></td>
						<td><div id="puttickettimeTip" style="width:250px"></div></td>
					</tr>  --%>
					<tr>
						<td align="right">途经站1：</td>
						<td><input id="viastaion1" name="viastaion1" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" value="${trainList.viastaion1 }"></td>
						<td><div id="viastaion1Tip" style="width:250px"></td>
					</tr>
					<tr>
						<td align="right">途经站2：</td>
						<td><input id="viastaion2" name="viastaion2" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" value="${trainList.viastaion2 }"></td>
						<td><div id="viastaion2Tip" style="width:250px"></td>
					</tr>
					<tr>
						<td align="right">途经站3：</td>
						<td><input id="viastaion3" name="viastaion3" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" value="${trainList.viastaion3 }"></td>
						<td><div id="viastaion3Tip" style="width:250px"></td>
					</tr>
					<tr>
						<td align="right">途经站4：</td>
						<td><input id="viastaion4" name="viastaion4" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" value="${trainList.viastaion4 }"></td>
						<td><div id="viastaion4Tip" style="width:250px"></td>
					</tr>
					<tr>
						<td align="right">途经站5：</td>
						<td><input id="viastaion5" name="viastaion5" class="form-control" style="width:160px;height:25px;" onclick="this.value='';GetCityList(this);" onkeyup="selCity(event, this)" value="${trainList.viastaion5 }"></td>
						<td><div id="viastaion5Tip" style="width:250px"></td>
					</tr>
					<tr>
						<td align="right">车票数：</td>
						<td><input id="total" name="total" class="form-control" style="width:160px;height:25px;" value="${trainList.total }"></td>
						<td><div id="totalTip" style="width:250px"></td>
					</tr>
					<tr>
					<td align="right">车厢数量：</td>
						<td>
							<select id="compartmentsnumber" name="compartmentsnumber" class="form-control" style="width:160px;height:30px;">
								<option value="1" <c:if test="${trainList.compartmentsnumber == 1 }">selected</c:if>>1</option>
								<option value="2" <c:if test="${trainList.compartmentsnumber == 2 }">selected</c:if>>2</option>
								<option value="3" <c:if test="${trainList.compartmentsnumber == 3 }">selected</c:if>>3</option>
								<option value="4" <c:if test="${trainList.compartmentsnumber == 4 }">selected</c:if>>4</option>
								<option value="5" <c:if test="${trainList.compartmentsnumber == 5 }">selected</c:if>>5</option>
								<option value="6" <c:if test="${trainList.compartmentsnumber == 6 }">selected</c:if>>6</option>
								<option value="7" <c:if test="${trainList.compartmentsnumber == 7 }">selected</c:if>>7</option>
								<option value="8" <c:if test="${trainList.compartmentsnumber == 8 }">selected</c:if>>8</option>
								<option value="9" <c:if test="${trainList.compartmentsnumber == 9 }">selected</c:if>>9</option>
								<option value="10" <c:if test="${trainList.compartmentsnumber == 10 }">selected</c:if>>10</option>
							</select>
						</td>
						<td></td>
					</tr>
					<tr>
						<td align="right">上铺座位数：</td>
						<td>
							<select id="spnumber" name="spnumber" class="form-control" style="width:160px;height:30px;">
								<option value="100" <c:if test="${trainList.spnumber == 100 }">selected</c:if>>100</option>
								<option value="120" <c:if test="${trainList.spnumber == 120 }">selected</c:if>>120</option>
								<option value="140" <c:if test="${trainList.spnumber == 140 }">selected</c:if>>140</option>
								<option value="160" <c:if test="${trainList.spnumber == 160 }">selected</c:if>>160</option>
								<option value="180" <c:if test="${trainList.spnumber == 180 }">selected</c:if>>180</option>
								<option value="200" <c:if test="${trainList.spnumber == 200 }">selected</c:if>>200</option>
							</select>
						</td>
						<td></td>
					</tr>
					<tr>
						<td align="right">中铺座位数：</td>
						<td>
							<select id="zpnumber" name="zpnumber" class="form-control" style="width:160px;height:30px;">
								<option value="100" <c:if test="${trainList.zpnumber == 100 }">selected</c:if>>100</option>
								<option value="120" <c:if test="${trainList.zpnumber == 120 }">selected</c:if>>120</option>
								<option value="140" <c:if test="${trainList.zpnumber == 140 }">selected</c:if>>140</option>
								<option value="160" <c:if test="${trainList.zpnumber == 160 }">selected</c:if>>160</option>
								<option value="180" <c:if test="${trainList.zpnumber == 180 }">selected</c:if>>180</option>
								<option value="200" <c:if test="${trainList.zpnumber == 200 }">selected</c:if>>200</option>
							</select>
						</td>
						<td></td>
					</tr>
					<tr>
						<td align="right">下铺座位数：</td>
						<td>
							<select id="xpnumber" name="xpnumber" class="form-control" style="width:160px;height:30px;">
								<option value="100" <c:if test="${trainList.xpnumber == 100 }">selected</c:if>>100</option>
								<option value="120" <c:if test="${trainList.xpnumber == 120 }">selected</c:if>>120</option>
								<option value="140" <c:if test="${trainList.xpnumber == 140 }">selected</c:if>>140</option>
								<option value="160" <c:if test="${trainList.xpnumber == 160 }">selected</c:if>>160</option>
								<option value="180" <c:if test="${trainList.xpnumber == 180 }">selected</c:if>>180</option>
								<option value="200" <c:if test="${trainList.xpnumber == 200 }">selected</c:if>>200</option>
							</select>
						</td>
						<td></td>
					</tr>
					<tr>
						<td align="right">票价：</td>
						<td>
							<input id="price" name="price" class="form-control" style="width:160px;height:25px;"  value="${trainList.price }">
						</td>
						<td></td>
					</tr>
					<tr align="center">
						<td colspan="4">
							<input type="button" value="保存" id="btnUpdate" onclick="" 
							class="button button-pill button-primary" style="width:140px;height:40px;">
							&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="button" value="返回" id="exit" 
							class="button button-pill button-primary" style="width:140px;height:40px;">
						</td>
					</tr>
				</c:forEach>
			</table>
		</form>
	</center>
</body>
</html>